//
//@File    :	7.5_arrfun1.cpp
//@Time    :	2021/08/09 17:50:07
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	functions with an array argument
//

#include <iostream>
const int ArSize = 8;
int sum_arr(int arr[],int n);
using namespace std;
int main()
{
    int cookies[ArSize] = {1,2,4,8,16,32,64,128};
    //对以上数组求和
    int sum = sum_arr(cookies,ArSize);
    cout<<"Total cookies esten: "<<sum<<"\n";
    system("pause");
    return 0;
}
int sum_arr(int arr[],int n)
{
    int total = 0;
    for (int i = 0; i < n; i++)
    {
        total = total + arr[i];
    }
    return total;
}